{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bd425409-3cc8-49a2-ab6f-3dcf3a88716f",
   "metadata": {},
   "outputs": [],
   "source": [
    "filename = \"human2.fna.line\"\n",
    "data_file = open(filename, 'r')\n",
    "\n",
    "out_train_filename = \"human2.fna.line.train\"\n",
    "out_train_file = open(out_train_filename, 'w')\n",
    "\n",
    "out_valid_filename = \"human2.fna.line.valid\"\n",
    "out_valid_file = open(out_valid_filename, 'w')\n",
    "\n",
    "line_num = 0\n",
    "select_line_num = 0\n",
    "\n",
    "for line in data_file:\n",
    "    if 0==line_num%3: #取1/3数据\n",
    "        if select_line_num%100: #取1%做校验\n",
    "            out_train_file.write(line)\n",
    "        else:\n",
    "            out_valid_file.write(line)\n",
    "        select_line_num = select_line_num + 1\n",
    "\n",
    "    line_num = line_num + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04588686-1eb1-48f6-8f44-8f9880f015ac",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
